package org.example.zsbback01.controller;

import org.example.zsbback01.vo.R;
import org.example.zsbback01.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@CrossOrigin(origins = "http://localhost:5500")
@RestController
public class BookController {
    @Autowired
    private BookService bookService;
    @GetMapping("/books")
    public R getBooks(@RequestParam(defaultValue = "1") int page,
                      @RequestParam(defaultValue = "2") int limit,
                      @RequestParam (defaultValue = "") String name){
        return R.ok(bookService.findAllBooks(page, limit, name));
    }
}
